    const webpackMerge = require('webpack-merge');
    const webpack = require('webpack');
    const ExtractTextPlugin = require('extract-text-webpack-plugin');
    const WebpackMd5Hash = require('webpack-md5-hash');

    const baseConfig = require('./config/base.js');
    const config = require('./config/config');
    const defPath = config.defPath;
    const APP_PATH = defPath.APP_PATH;

    module.exports = webpackMerge(baseConfig, {
        entry: {
            app: defPath.ENTRY_PATH,
            vendor: config.vendor
        },
        output: {
            path: defPath.BUILD_PATH,
            // 所有输出文件的目标路径
            filename: 'js/bundle.js?[chunkhash]',   // 输出文件命名
            publicPath: '/',        // 必须写，且与 devServer 的 publicPath 保持一致
            chunkFilename: 'js/[name].js?[chunkhash]'  // 分块文件命名
        },
        module: {
            rules: [
               {
                    test:/\.html$/,
                    use: {
                        loader: 'html-loader'
                    }
                },
                {
                    test: /\.jsx?$/,
                    exclude: /node_modules/,
                    loader: 'babel-loader',
                    options: {
                      cacheDirectory: true,
                      presets: ['env', 'stage-2', 'react'],
                      plugins: ['transform-runtime'],
                    },
                },
                {
                    test: /\.(less|css)$/,
                    include: APP_PATH,
                    use: ExtractTextPlugin.extract({    // css 单独打包，（2.x 改变很大）
                        fallback: 'style-loader',
                        use: 'css-loader!less-loader' + config.sassLoaderConfig
                    })
                }, {
                    test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif|mp4|webm)(\?\S*)?$/,
                    include: APP_PATH,
                    loader: 'url-loader?limit=8192&name=images/[name].[ext]?[hash]'
                }
            ]
        },
        plugins: [
            new WebpackMd5Hash(),   // 取代标准webpack chunkhash
            new webpack.DefinePlugin({
                'process.env.NODE_ENV': JSON.stringify('production')
            }),

            // js 压缩
            new webpack.optimize.UglifyJsPlugin(config.uglifyJsConfig),
            new webpack.optimize.CommonsChunkPlugin({
                names: [
                    'vendor'
                ],
                filename: 'js/[name].js?[chunkhash]',
                minChunks: Infinity
            }),
            // new ChunkManifestPlugin({
            //     filename: 'chunk-manifest.json',
            //     manifestVariable: 'webpackManifest'
            // }),
            // css 抽取
            new ExtractTextPlugin({
                filename: 'css/styles.css?[contenthash]',
                disable: false,
                allChunks: true
            })
        ]
    })